Skip to content

tests: add key image spent status lifecycle test#10334

Closed
DUQUEredes wants to merge 1 commit intomonero-project:masterfrom
DUQUEredes:add-key-image-spent-test
Closed

tests: add key image spent status lifecycle test#10334
DUQUEredes wants to merge 1 commit intomonero-project:masterfrom
DUQUEredes:add-key-image-spent-test

Conversation

@DUQUEredes
Copy link

@DUQUEredes DUQUEredes commented Feb 23, 2026

Summary

  • Add standalone functional test is_key_image_spent.py covering the full lifecycle of key image spent status codes
  • The existing test in transfer.py only covers status 0 (UNSPENT) and 1 (SPENT_IN_BLOCKCHAIN); status 2 (SPENT_IN_POOL) is never tested
  • This test verifies all three status codes and their transitions: pool→blockchain, pool→flush→unspent, and mixed-state batch queries
  • Added to DEFAULT_TESTS in functional_tests_rpc.py so it runs in CI

Test cases

Test What it proves
check_unspent Wallet key images return status 0 before any spending
check_spent_in_pool Key images in mempool return status 2
check_spent_in_blockchain After mining, status transitions 2 → 1
check_flush_returns_to_unspent After flush_txpool, status reverts 2 → 0
check_mixed_states Single batch query with all 3 statuses returns correct per-key-image results
check_edge_cases Empty list, unknown key images, duplicate key images in one call

Test plan

  • All assertions pass against monerod v0.18.1.0 in regtest mode
  • Status 2 (SPENT_IN_POOL) correctly observed
  • Added to functional_tests_rpc.py DEFAULT_TESTS
  • Reviewer runs PYTHONPATH=utils/python-rpc python3 tests/functional_tests/is_key_image_spent.py with monerod + wallet-rpc in regtest

🤖 Generated with Claude Code

Test is_key_image_spent RPC across all three status codes (0=UNSPENT,
1=SPENT_IN_BLOCKCHAIN, 2=SPENT_IN_POOL). The existing test in
transfer.py only covers status 0 and 1. This adds coverage for the
mempool-specific status 2 and verifies lifecycle transitions:
pool->blockchain, pool->flush->unspent, and mixed-state batch queries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DUQUEredes DUQUEredes force-pushed the add-key-image-spent-test branch from 5c0013f to 8688093 Compare February 23, 2026 12:54
@selsta
Copy link
Collaborator

selsta commented Feb 24, 2026

As for tests: don't accept new test just for the sake of tests. New tests should be added together with an entirely new code, or together with bugfixes - i.e. a test that makes the old code fail + the code fix

Please only submit PRs that are clear bug or logic fixes. AI generated pull requests that add vague test cases with no clear benefit, or other changes that are not done with clear purpose will get closed.

@selsta selsta closed this Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants